package cheme.ProcessModel;

import cheme.ProcessModel.ProcessUnits.Streams.Tags.OverallTagComponent;

public class OverallTagComponentInitPolicy
{
	IdGenerator tagIdGenerator = null;
	
	protected IdGenerator getTagIdGenerator()
	{
		if(null == tagIdGenerator)
		{
			tagIdGenerator = new IdGenerator(ProcessModelConstants.TAG_OVERALL_COMPONENT_BASE_NAME);
		}
		
		return tagIdGenerator;
	}

	protected void setTagIdGenerator(IdGenerator tagIdGenerator)
	{
		this.tagIdGenerator = tagIdGenerator;
	}
	
	protected String getNextTagOverallComponentId()
	{
		return getTagIdGenerator().createId();
	}
	
	public void initialize(OverallTagComponent component)
	{
		if(component.getLabel().isEmpty())
		{
			component.setLabel(getNextTagOverallComponentId());
		}
		
		if(component.getQuantity().isEmpty())
		{
			component.setQuantity(ProcessModelConstants.TAG_COMPONENT_DEFAULT_QUANTITY);
		}
	}
}
